package day6;

import java.util.Scanner;

public class Vehicle {
    public int speed;
    public int size;
    public static void main(String[] args) {
        Vehicle car=new Vehicle();
        car.speed=0;
        car.size=1500;
        Scanner sc=new Scanner(System.in);
        int result=car.setSpeed(car.speed);
        System.out.println("当前速度为："+result);
        System.out.println("***********************");
        System.out.println(" 1.加速 | 2.减速 | 0.退出");
        System.out.println("***********************");

        for (int i=0;i<100;i++){
            System.out.print("请输入对应的数字：");
            int num=sc.nextInt();

            switch (num){
                case 0:return;
                case 1:
                    int add=car.speedUp();
                    System.out.println("当前速度为："+(result+add));
                    car.move();
                    continue;
                case 2:
                    int down=car.speedDown();
                    System.out.println("当前速度为："+(result-down));
                    car.move();
                    continue;
                default: System.out.println("输入有误！请重新输入");
            }
        }

    }
    public void move(){
        System.out.println("我正在开车!车的体积为："+size);
    }
    public int setSpeed(int speed) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请设置你的速度：");
        int sp=sc.nextInt();
        return sp+speed;
    }
    public int speedUp() {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入要增加的速度：");
        int add=sc.nextInt();
        return add;
    }
    public int speedDown() {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入要降低的速度：");
        int down=sc.nextInt();
        return down;
    }
}
